<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge" />
<link rel="shortcut icon" href="static/style/images/favicon.ico" />
<!-- [EasyUI] -->
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/gray/easyui.css" />
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/icon.css" />
<script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
<!-- [扩展样式] -->
<link rel="stylesheet" type="text/css" href="/static/css/dreamlu.css" />
<link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
<link rel="stylesheet" type="text/css" href="/static/css/login.css" />
<!--<script type="text/javascript" src="static/js/login.js" charset="utf-8"></script>-->
<title>搜索热词管理</title>
<script type="text/javascript">

    var dataGrid;
    var flag = 1;

    $(function () {
 	    //用户维护（新增、修改）界面
        $("#importDialog").dialog({
            title: "新增",
            width: 400,
            height: 170,
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '保存',
                handler: function () {
                    importUser();
                }
            }, {
                text: '关闭',
                handler: function () {

                    $("#importDialog").dialog("close");
                }
            }]
        });
        //首次进入拉取
        dataGrid = $('#dataGrid').datagrid({
            url: '/getmedialist',
            method:'get',
            fit: true,
            striped: true,
            rownumbers: true,
            singleSelect: true,
            pagination: true,
            pageSize: 30,
            pageList: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
            idField: 'id',
            columns: [[{
                width: '20%',
                title: ' id',
                field: 'id',
                hidden: true
            }, {
                width: '80%',
                title: '文件名',
                field: 'file_name'
            }, {
                field: 'action',
                title: '操作',
                width: '20%',
                formatter: function (value, row, index) {
                    var str = '';
                    str += $.formatString('<a href="javascript:void(0)" class="user-easyui-linkbutton-del" data-options="plain:true,iconCls:\'icon-del\'" onclick="deleteFun(\'{0}\');" >删除</a>', row.id);
                    return str;
                }
            }]],
            onLoadSuccess: function (data) {
                if (data.total >= 10){
                    flag = 0
                }else{
                    flag = 1
                }
                $('.user-easyui-linkbutton-del').linkbutton({text: '删除', plain: true, iconCls: 'icon-del'});
            },
            toolbar: '#toolbar'
        });
        });

        //新增用户
        function addFun() {
            $("#importForm").form("clear");
            $("#importDialog").dialog("open");
        }

        //批量导入
        function importUser() {
            $("#importForm").form("submit", {
                url: "/addmedia?type=" + $("#type").combobox('getValue'),
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == "0") {
                        $("#importDialog").dialog("close");
                        HdUtil.messager.slide(data.msg);
                        $("#dataGrid").datagrid("reload");
                    } else {
                        $("#importDialog").dialog("close");
                        HdUtil.messager.error(data.msg);
                    }
                }
            });
        }
        //删除
        function deleteFun(id) {
            $.messager.confirm(HdUtil.constant.CONFIRM, HdUtil.constant.DELETE_CONFIRM, function (r) {
                    if (r) {
                        $.ajax({
                            method: "post",
                            url: "/delmedia",
                            data: {
                                id: id
                            },
                            success: function (data) {
                                if (data.code == "0") {
                                    HdUtil.messager.slide(HdUtil.constant.DELETE_SUCCESS);
                                    $("#dataGrid").datagrid("reload");
                                } else {
                                    HdUtil.messager.error(data.msg);
                                }
                            }
                        })
                    }
                });

        }


        function searchFun() {
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }
        function cleanFun() {
            $('#searchForm input').val('');
            dataGrid.datagrid('load', {});
        }
    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
<div data-options="region:'north',border:false" style="height: 30px; overflow: hidden;background-color: #fff">
  <form id="searchForm">
    <table>
      <tr>
        <th>文件分类:</th>
        <td><select id="type" data-options="required:true" class="easyui-combobox" name="type" style="width: 120px">
                    <option value="0">题库图片</option>
                    <option value="1">解析图片</option>
                    <option value="2">解析语音</option>
                    <option value="3">VIP解析图片</option>
                </select></td>
          <th>文件名:</th>
          <td><input name="file_name" placeholder=""/></td>
        <td>


          <a href="javascript:void(0);" class="easyui-linkbutton"
                       data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">查询</a><a
                        href="javascript:void(0);" class="easyui-linkbutton"
                        data-options="iconCls:'icon-cancel',plain:true" onclick="cleanFun();">清空</a> </td>
      </tr>
    </table>
  </form>
</div>
<div data-options="region:'center',border:true,title:'信息列表'">
  <table id="dataGrid" data-options="fit:true,border:false">
  </table>
</div>
<div id="toolbar" style="display: none;"> <a id="a_add" onclick="addFun();" href="javascript:void(0);" class="easyui-linkbutton"
           data-options="plain:true,iconCls:'icon-add'">添加</a>
 </div>
<div id="importDialog">
    <form id="importForm" enctype="multipart/form-data" method="post">
        <input type="file" name='file'/>
    </form>
</div>

</body>
</html>
